package com.suxii.todomvi.di

import android.content.Context
import com.suxii.todomvi.data.local.TodoDao
import com.suxii.todomvi.data.local.TodoDatabase
import com.suxii.todomvi.domain.repository.TodoRepository
import com.suxii.todomvi.data.repository.TodoRepositoryImpl
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object ModelModule {

    @Singleton
    @Provides
    fun providerDatabase(@ApplicationContext context: Context): TodoDatabase {
        return TodoDatabase.getInstance(context)
    }

    @Provides
    fun providerDao(todoDatabase: TodoDatabase): TodoDao {
        return todoDatabase.getTodoDao()
    }

    @Provides
    fun providerTodoRepository(todoDao: TodoDao): TodoRepository = TodoRepositoryImpl(todoDao)

}